/*
 * TextField.java
 *
 * Created on 30 de agosto de 2007, 04:41 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package ig.formato.util;

/**
 *
 * @author jsanchez
 */
public class StaticField implements Comparable{
    private Integer banda=null;
    private String text=null;
    private Integer x=null;
    private Integer y=null;
    private Integer w=null;
    private Integer h=null;
    private Integer sizeText=null;
    private String justificacion=null;
    private Integer idice=null;
    private boolean reSisseText=true;
    private boolean borde=false;
    private boolean contar;
    
    /** Creates a new instance of TextField */
    public StaticField() {
    }
    
    public String getText() {
        return text;
    }
    
    public void setText(String _text) {
        String[] palabras=_text.trim().split(" ");
        this.text="";
        for (int i = 0; i < palabras.length; i++) {
            if(this.text.length()>0)
                this.text=this.text+"\n";
            if(isReSisseText()){
                if(this.w/4 < palabras[i].length())
                    this.w=(palabras[i].length()*4);
            }
            this.text=this.text+palabras[i];
        }
    }
    
    public Integer getX() {
        return x;
    }
    
    public void setX(Integer x) {
        this.x = x;
    }
    
    public Integer getY() {
        return y;
    }
    
    public void setY(Integer y) {
        this.y = y;
    }
    
    public Integer getW() {
        return w;
    }
    
    public void setW(Integer w) {
        this.w = w;
    }
    
    public Integer getH() {
        return h;
    }
    
    public void setH(Integer h) {
        this.h = h;
    }
    
    public Integer getSizeText() {
        return sizeText;
    }
    
    public void setSizeText(Integer sizeText) {
        this.sizeText = sizeText;
    }
    
    public String getJustificacion() {
        return justificacion;
    }
    
    public void setJustificacion(String justificacion) {
        this.justificacion = justificacion;
    }
    
    public Integer getBanda() {
        return banda;
    }
    
    public void setBanda(Integer banda) {
        this.banda = banda;
    }
    
    public int compareTo(Object o) {
        return this.getIdice().compareTo(((StaticField)o).getIdice());
    }
    
    public Integer getIdice() {
        return idice;
    }
    
    public void setIdice(Integer idice) {
        this.idice = idice;
    }
    
    public String toString(){
        StringBuilder staticText=new StringBuilder("");
        staticText.append("<staticText>\n");
        staticText.append("<reportElement\n");
        if(!x.equals(0))
            staticText.append("        x=\""+(x+0)+"\"\n");        
        else
            staticText.append("        x=\""+x+"\"\n");
        staticText.append("        y=\""+y+"\"\n");
        staticText.append("        width=\""+(w-0)+"\"\n");
        staticText.append("        height=\""+h+"\"\n");
        staticText.append("        forecolor=\"#000000\"\n");
        staticText.append("        key=\"staticText-1\"/>\n");
        if(borde)
            staticText.append("<box topBorder=\"Thin\" topBorderColor=\"#000000\" leftBorder=\"Thin\" leftBorderColor=\"#000000\"  rightBorder=\"Thin\" rightBorderColor=\"#000000\" bottomBorder=\"Thin\" bottomBorderColor=\"#000000\"/>\n");
        else
            staticText.append("<box topBorder=\"Thin\" topBorderColor=\"#000000\" leftBorder=\"Thin\" leftBorderColor=\"#000000\"  bottomBorder=\"Thin\" bottomBorderColor=\"#000000\"/>\n");
        staticText.append("<textElement textAlignment=\""+this.justificacion+"\" verticalAlignment=\"Middle\">\n");
        staticText.append("        <font pdfFontName=\"Helvetica-Bold\" size=\""+this.sizeText+"\" isBold=\"false\"/>\n");
        staticText.append("</textElement>\n");
        staticText.append("<text><![CDATA["+this.text+"]]></text>\n");
        staticText.append("</staticText>\n");
        return staticText.toString();
    }
    
    
    public void setContar(boolean contar) {
        this.contar=contar;
    }
    
    public boolean isContar() {
        return contar;
    }
    
    public boolean isReSisseText() {
        return reSisseText;
    }
    
    public void setReSisseText(boolean reSisseText) {
        this.reSisseText = reSisseText;
    }

    public boolean isBorde() {
        return borde;
    }

    public void setBorde(boolean borde) {
        this.borde = borde;
    }
}
